package com.job.liushuang.HomeWork0722.No1;

/**
 * @author Liushuang
 * @version 1.0
 * @since 2022-07-22 21:00:30
 */
public class TestStudent {
    public static void main(String[] args) throws Exception {
        Student sc=new Student();
        sc.setAge(28);
    }
    public void setAge(int age)throws Exception{
        if (age <18||age >28){
            throw new Exception("年龄异常");
        }else {
            this.setAge(age);//赋值
        }
    }
}
